package com.wgy.day13.Random随机产生数字;

import java.util.Random;
import java.util.Scanner;

public class Demo07RandomGame {
    public static void main(String[] args) {
        Random r = new Random();
        int a = r.nextInt(100) + 1;


        while (true) {
            System.out.println("请输入你猜测的数字");
            Scanner sc = new Scanner(System.in);
            int gussNum = sc.nextInt();


            if (gussNum > a) {
                System.out.println("太大,请重试");
            } else if (gussNum < a) {
                System.out.println("太小,请重试");
            } else {
                System.out.println("恭喜你,猜对了");
                System.out.println("游戏结束");
                break;
            }

        }

    }
}
